﻿using MS.Common;
using Prism.Commands;
using Prism.Events;
using Prism.Ioc;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Unity;

namespace wpf.Basics.ViewModels
{
    //https://www.bootcss.com/p/font-awesome/design.html
    public class BedViewModel : VmBase
    {
        public DelegateCommand<object> NavCommand { get; set; }

        #region 属性
        private List<IconMenu> _ListMenu;
        /// <summary>
        /// 导航头集合
        /// </summary>
        public List<IconMenu> MenuList
        {
            get { return _ListMenu; }
            set { _ListMenu = value; }
        }


        #endregion
        public BedViewModel(IContainerExtension container, IEventAggregator eventAggregator, IRegionManager regionManager) : base(container, eventAggregator, regionManager)
        {
            #region 时间绑定
            this.NavCommand = new DelegateCommand<object>(OnNavCommand);
            #endregion
            //unicode 编码 1.绑定加 \u
            //2.直接写入 text 加 &#x ;
            //https://www.bootcss.com/p/font-awesome/design.html
            MenuList = new List<IconMenu>() { new IconMenu() { Name="预检分诊",Path= "GetTriage", ICONNAME= "\uf0e8" }, new IconMenu() { Name = "护理记录", Path = "GetNursingView", ICONNAME = "\uf0f7" } };

            InitMenu();
        }
        public void InitMenu() 
        {
            IconMenu menu= MenuList?.FirstOrDefault();
            OnNavCommand(menu);
        }
        /// <summary>
        /// 触发导航
        /// </summary>
        /// <param name="obj"></param>
        public void OnNavCommand(object obj)
        {
            IconMenu menu= obj as IconMenu;
            string navStr = menu.Path.ToString();
            regionManager.RequestNavigate(RegionName.ShellMainRegionName, navStr);
            
        }

    }

    /// <summary>
    /// 导航实体
    /// </summary>
    public class IconMenu
    {

        public string Name { get; set; }
        public string Path { get; set; }
        public string ICONNAME { get; set; }
    }
}
